import 'package:flutter/material.dart';

class CountButton extends StatelessWidget {
  String text;
  int remainSeconds;
  VoidCallback onPressed;

  CountButton(this.text, this.remainSeconds, this.onPressed);

  @override
  Widget build(BuildContext context) {
    double height = 40;
    double width = 80;
    var textStyle = TextStyle(color: Colors.white, fontSize: 16);
    return GestureDetector(
      onTap: () {
        if (remainSeconds < 1) {
          this.onPressed();
        }
      },
      child: Container(
        width: width,
        height: height,
        alignment: Alignment.center,
        decoration: ShapeDecoration(
          color: Colors.orange,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.all(Radius.circular(8.0)),
          ),
        ),
        child: Container(
          alignment: Alignment.center,
          child: Text(
            remainSeconds < 1 ? text : "${this.remainSeconds}秒",
            style: textStyle,
          ),
        ),
      ),
    );
  }
}
